from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet


from apps.meiduo_admin.serializers.permission import PermissionSerializer, ContentTypeSerializer
from apps.meiduo_admin.utils import PageNum

#######权限管理获取#######
class PermissionView(ModelViewSet):

    # 指定序列化器
    serializer_class = PermissionSerializer
    #指定查询集
    queryset = Permission.objects.all()
    #指定分页器
    pagination_class = PageNum


    #######获取所有权限类型
    def simple(self,request):
        # 1.查询权限类型表
        data = ContentType.objects.all()
        # 2.返回权限类型
        ser = ContentTypeSerializer(data,many=True)
        return Response(ser.data)